
//
//  CashHandFirstTBV.m
//  XJMTechnician
//
//  Created by Mr.hu on 2017/10/17.
//  Copyright © 2017年 Mr.hu. All rights reserved.
//

#import "CashHandFirstTBV.h"
#import "CashHandSecondTBV.h"
#import "RemindPaySecretAlert.h"
#import "CashHandSecondTBV.h"

@interface CashHandFirstTBV ()<UITextFieldDelegate>


@property (weak, nonatomic) IBOutlet UILabel *AccountAlipaylab; //废弃

@property (weak, nonatomic) IBOutlet UILabel *AccountRemin_Cash;
@property (weak, nonatomic) IBOutlet UIButton *AccountBringSubmit;
@property (weak, nonatomic) IBOutlet UITextField *AccountBring_Cash;
/** 注释 **/
@property (strong, nonatomic) RemindPaySecretAlert * remindnews;
@property (weak, nonatomic) IBOutlet UITextField *Account_textField;

@end

@implementation CashHandFirstTBV

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController setNavigationBarHidden:NO];
    [self addLeftBtn:[UIImage imageNamed:@"fanhui"] Action:@selector(backToPrevious)];
    self.title = @"收入提现";
    self.AccountBring_Cash.delegate = self;
    self.Account_textField.delegate = self;
    
    self.AccountBringSubmit.layer.cornerRadius = 22;
    self.AccountBringSubmit.layer.masksToBounds = YES;
    
    NSString * firststr =  [self.CashHand_price stringByReplacingOccurrencesOfString:@"¥" withString:@""];
    self.AccountBring_Cash.placeholder = firststr;
    self.AccountRemin_Cash.text = [NSString stringWithFormat:@"当前收入余额%@元",firststr];
    self.AccountRemin_Cash.textColor = RGBA(145, 145, 145, 1);
    
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jkr_tapGestureAction:)];
    tapGestureRecognizer.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tapGestureRecognizer];
}

- (void)jkr_tapGestureAction:(UITapGestureRecognizer *)tapGusture{
    [self.view endEditing:YES];
}

- (IBAction)BringCashMeth:(id)sender {
    
    self.remindnews = [[RemindPaySecretAlert alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    self.remindnews.backgroundColor = RGBA(95, 94, 86, 0.8);
    
    self.remindnews.bring_money.text = [NSString stringWithFormat:@"¥ %@",self.AccountBring_Cash.text];
    
    self.remindnews.bring_money.textColor = RGBA(51, 51, 51, 1);
    [self.remindnews.Payingexitbtn addTarget:self action:@selector(bindingroutOnclicked) forControlEvents:UIControlEventTouchUpInside];
    [[UIApplication sharedApplication].keyWindow addSubview:self.remindnews];
}

- (IBAction)AllCash_PriceMeth:(id)sender {
    
    NSString * firststr =  [self.CashHand_price stringByReplacingOccurrencesOfString:@"¥" withString:@""];
    self.AccountBring_Cash.text = firststr;
}

- (void)bindingroutOnclicked{
    
//    self.remindnews.PaySecret
    //page 1：支付宝 2：微信
    [XJHttpClass Techeradd_cashtoken:[XJToolClass getToken] type:@"1" cash_account:self.Account_textField.text cash_money:self.AccountBring_Cash.text paypwd:self.remindnews.PaySecret andFinishblock:^(id response, NSString *errStr) {
        
        [self.remindnews removeFromSuperview];
        
        if (errStr) {
            [XJToolClass tipAnimationWith:errStr];
        }else{
            
            CashHandSecondTBV * cashSec = [[CashHandSecondTBV alloc]init];
            cashSec.cashHand_Price = self.Account_textField.text;
            cashSec.cashHand_Account = self.AccountBring_Cash.text;
            [self.navigationController pushViewController:cashSec animated:YES];
        }
    }];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [self.AccountBring_Cash resignFirstResponder];
    [self.Account_textField resignFirstResponder];
    
    return NO;
}



@end
